
* Code for JHR17 paper.
* Lyle Scruggs
* version November 20, 2017
 
* 1) Original ISA paper codes, with add'l datasets are in "isa16analysis.do"
* 2) The code for the original (ISA 2016, Atlanta) paper is in jhrrev17

*    


/*This code should reproduce the tables reported in the Scruggs JHR paper*/

use "root~/jhrcomb17simple.dta", replace
sort cname year
gen myclass=1 if uc==1  
replace myclass=2 if ic==1 
replace myclass=3 if wc==1
replace myclass=4 if se==1
  
  /* uc=upper class, ic=intermediate class, wc= working class, and se= self-employed */

for var female eduhi myclass union left old : table cname X year [aweight=weight],  c(mean HRHa) format(%9.3g)

table cname year  [aweight=weight], c(mean HRHa)
table cname year if edihi==1 [aweight=weight], c(mean HRHa)
table cname year if uc==1 [aweight=weight], c(mean HRHa)
table cname year if ic==1 [aweight=weight], c(mean HRHa)
table cname year if wc==1 [aweight=weight], c(mean HRHa)
table cname year if se==1 [aweight=weight], c(mean HRHa)
table cname year if female==1 [aweight=weight], c(mean HRHa)
table cname year if unionmem==1 [aweight=weight], c(mean HRHa)
table cname year if old==1 [aweight=weight], c(mean HRHa)
table cname year if left==1 [aweight=weight], c(mean HRHa)


/* Generates the logit model results provided in Data Appendix to Scruggs JHR paper*/
/* The do loops are divided 1/15, 16/30, 31/43 for organizational reasons */

drop if year==1990

forvalues i=1/15 {
qui logistic HRHalt i.female i.eduhis i.young i.old i.ue i.unionmem i.uc i.ic i.se i.wc i.left [pweight=weight] if ccy==`i', robust 
eststo p`i'
}
outreg2 [p*] using out1a.xls, ctitle(index`i') replace
 eststo clear
 
forvalues i=16/30 {
qui logistic HRHalt i.female i.eduhis i.young i.old i.ue i.unionmem i.uc i.ic i.se i.wc i.left [pweight=weight] if ccy==`i', robust 
eststo p`i'
}
outreg2 [p*] using out1b.xls, ctitle(index`i') replace
eststo clear

forvalues i=31/43 {
qui logistic HRHalt i.female i.eduhis i.young i.old i.ue i.unionmem i.uc i.ic i.se i.wc i.left [pweight=weight] if ccy==`i', robust 
eststo p`i'
}
outreg2 [p*] using out1c.xls, ctitle(index`i') replace


/****************************************************************
This code below is supplemental. It helps to see how the original 
downloaded file was converted to the file included with the paper
i.e., to the file /jhrcomb17simple.dta
*****************************************************************
/* The cumulative role of government citation is:
ISSP Research Group (2008) International Social Survey Programme: Role of ///
Government I-IV - ISSP 1985-1990-1996-2006. GESIS Data Archive, Cologne. ZA4747 ///
Data file Version 1.0.0, doi:10.4232/1.4747 
*/

*Code Last modified 9/5/2017

*NOTE: The RoG file used here was modified after download to generate self-employment data from variable "wrktype"
*Self-employment data is needed for the social class measure used in lieu of income
*USERS MUST (RE)GENERATE SELF EMPLOYMENT VARIABLE IF THEY START FROM ORIGINAL SOURCE DOWNLOAD (i.e., from GESIS)  


 use "root~/cumrog8506ZA4747.dta" /*this is the file with the Scruggs (2018) J Human Rights archive download*/
 
 keep  V3 V4 V6 V7  V50 V52 V53 V55  V58 sex age marital educyrs VOTE_LE class ISCO88 union wrktype wrkst wrksup selfemp nemploy religgrp attend PARTY_LR hhcycle weight
 ren V3 caseid
 ren V4 year
 ren V6 country
 ren V7 cyear
 ren V50 grejob
 ren V52 grehealth
 ren V53 greold
 ren V55 greunem
  ren V58 grehousing
 
 /***Q: On the whole, do you think it should be or should not be the government's 
 responsibility to: provide decent housing for those who can't afford it (4 point scale).*/
 
 ren wrksup supervisor
 recode wrkst 11=5 12=1 /* There is no further classification of non-employed in the 1985 survey; only employed, unemployed, other*/

  /**needed to add self-employed to 2006 survey from wrktype*/
 replace selfemp=1 if wrktype==4 & year==2006
 replace selfemp=2 if wrktype~=4 & year==2006
 
 /***ISCO88 recodes for Erickson-Goldthorpe */
 /*** The ISSP gives only number employees/supervised Q to the self-employed. We code all  
 who supervise without indicating a number as supervising  1 person for the isko code*/
 
 replace nemploy=1 if supervisor==1 & nemploy==.
 iskoegp gepclass, isko(ISCO88) sempl(selfemp) supvis(nemploy)
 
sort year
save "root~/jhrcomb17.dta", replace
sort year

/*** generate HR score if all 5 positive, or if four positive and other missing, with all missing coded missing*/
/* This i the operationalization used in the Scruggs JHR paper */ 
 gen HRHalt=HRH
   replace HRHalt=1 if (grejob<=2 & grehealth<=2 &  greold<=2 & greunem<=2  & grehous>9) 
   replace HRHalt=1 if (grejob<=2 & grehealth<=2 &  greold<=2 & greunem>9 &  grehous<=2)  
   replace HRHalt=1 if (grejob<=2 & grehealth<=2 &  greold>9 & greunem<=2 &  grehous<=2)  
   replace HRHalt=1 if (grejob<=2 & grehealth>9 &  greold<=2 & greunem<=2 &  grehous<=2)   
   replace HRHalt=1 if (grejob>9 & grehealth<=2 &  greold<=2 & greunem<=2 &  grehous<=2) 
   replace HRHalt=. if (grejob==. & grehealth==. &  greold==. & greunem==. & grehous==. ) 
  
/***generates support scores for each of the five individual social programs***/
gen proue=  (greunem<=2)
   replace proue=. if greunem>8
gen proold=  (greold<=2)
   replace proold=. if greold>8 
gen prohealth=  (grehealth<=2)
   replace prohealth=. if grehealth>8 
gen projob= (grejob<=2 )
   replace grejob=. if grejob>8 
gen prohouse= (grehou<=2)
   replace grehou=. if grehou>8 

/****Creates dummy variables for use in regressions *****/ 
gen female=1 if sex==2
  replace female=0 if sex==1
gen eduhis=1 if educy<13
 replace eduhis=0 if educy>12 & educy~=99
gen edupost=1 if educy>16 & educy~=95 & educy~=97
 replace edupost=0 if educy<17 | educy==95 | educy==97
gen young=(age<30 & age<95)
gen old=(age>64 & age<95)
egen agecat=cut(age), at(12,30,40,50,65,95)
gen ue=(wrkst==5) 
  replace ue=. if wrkst==.
gen unionmem=(union==1)
  replace unionmem=0 if union==.
gen left=(PARTY_LR==1 | PARTY_LR==2)
  replace left=. if PARTY_LR==.

	/* Codes to deal with the coding of occupational class */  
	replace gepclass=60 if wrkst==6
	replace gepclass=60 if wrkst~=6 & (educy==95 | educyrs==96) & age<22
	replace gepclass=70 if wrkst==7 
	replace gepclass=80 if wrkst==8
	replace gepclass=90 if ue==1  

	/****** PUTS gepclass==. into self-employed based on reports in others variables*/
	replace gepclass=4 if gepclass>90 & selfemp==1 & nemp>=1 & nempl<9999
	replace gepclass=5 if gepclass>90 & selfemp==1 & nemp==.

	replace gepclass=2 if gepclass==. & (class==5 | class==6)
	replace gepclass=3 if gepclass==. & (class==4)
	replace gepclass=9 if gepclass==. & (class==1 | class==2)
  
	gen uc=(gepclass==1 | gepclass==2)
	replace uc=. if gepclass==. 
	gen ic=(gepclass==3 | gepclass==7)
	replace ic=. if gepclass==. 
	gen se=(gepclass==4 | gepclass==5 | gepclass==11)
	replace se=. if gepclass==. 
	gen wc=(gepclass>=8 & gepclass<=11)
	replace wc=. if gepclass==.
 
	gen ret=(gepclass==70)
	replace ret=. if gepclass==. & old==0
	gen hw=(gepclass==80)
	replace hw=. if gepclass==.
	gen stu=(gepclass==60)
	replace stu=. if gepclass==. & (educy<95 | educy==.)

	/***** 
	This creates a constant variables for country-years where a survey item is not asked
		Since it is a constant, these variables drop out of the regression analysis; 	
		Creating a constant is only needed as a device to prevent an error message in the regression do loops 	
	*****/
   label values year
	egen ccy=group(cname year) if year>1990
	for num 1 11  17 23 26 34: replace catholic=0 if ccy==X
	for num 1 11 15 17 18 30 31: replace norelig=0 if ccy==X 
	for num 1: replace unionmem=0 if ccy==X
	for num 11 17 18 21 24: replace left=0 if ccy==X
	for num 11: replace eduhis=0 if ccy==X
	labmask ccy, val(cyear)

	
save "root~/jhrcomb17simple.dta" , replace
